Page({
    data: {
      identityOptions: ['职场人', '学生'],
      selectedIdentityIndex: null,
      identity: ''
    },
    onLoad() {
      wx.setNavigationBarTitle({
        title: '选择身份'
      });
    },
    onIdentityChange(e) {
      const index = e.detail.value;
      this.setData({
        selectedIdentityIndex: index,
        identity: this.data.identityOptions[index]
      });
    },
    confirmIdentity() {
      if (this.data.identity) {
        wx.showToast({
          title: `选择了${this.data.identity}`,
          icon: 'success',
          duration: 2000
        });

        // 导航到对应页面
        wx.navigateTo({
          url: '/pages/userInfo/index'
        });
  
      } else {
        wx.showToast({
          title: '请选择您的身份',
          icon: 'none',
          duration: 2000
        });
      }
    },
    cancelIdentitySelection() {
      wx.navigateBack();
    }
  });